package rmi;


import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

import rmi.hello.Hello;
import rmi.hello.HelloImpl;
import rmi.sync.ISyncMgr;
import rmi.sync.SyncMgrImpl;

import common.Constant;

public class Server {

	public Server(){
		try {
			LocateRegistry.createRegistry(Constant.PORT);
			ISyncMgr syncMgr = new SyncMgrImpl();
			Naming.rebind("//127.0.0.1:" + Constant.PORT + "/syncMgr", syncMgr);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	/**
	 * @param args
	 * @throws RemoteException 
	 * @throws MalformedURLException 
	 */
	public static void main(String[] args){
		Server s = new Server();
//		Hello hello = new HelloImpl();
//		Naming.rebind("//127.0.0.1:" + Constant.PORT + "/hello", hello);
		System.out.println("sever is start");
	}

}
